<template>
  <div>
    <a-card class="info" title="印章资质使用申请">
      <template slot="extra">
        <template v-if="false">
          <a-button
              class="ruleButton"
              :ghost="true"
              type="primary"
              icon="edit"
              @click="handleEdit(model)"
              :disabled="isDisabledAuth('erpSealCertificationUseRecord:edit')"
          />
          <a-divider type="vertical"/>
  <!--        <a-button type="primary" size="small" @click="startProcess(model)"-->
  <!--                  :disabled="isDisabledAuth('erpSealCertificationUseRecord:startProcess')">发起流程-->
  <!--        </a-button>-->
        </template>
  <!--      <template v-if="showBtn(model.bpmStatus)&& doCount > 0">-->
  <!--        <span v-if="model.taskUrge">-->
  <!--          <a-icon title="催办提醒" theme="twoTone" twoToneColor="#eb2f96"-->
  <!--                  @click="taskNotifyMe(flowCode,model.id)" type="notification"/>-->
  <!--          <a-divider type="vertical"/>-->
  <!--        </span>-->

  <!--        <a-button type="primary" size="small" @click="handleProcess(model)">办理</a-button>-->
  <!--        <a-divider type="vertical"/>-->
  <!--      </template>-->
  <!--      <template v-if="myCount > 0 && showBtn(model.bpmStatus)">-->
  <!--        <a-button type="primary" size="small" @click="taskNotify(flowCode,model.masterId)">催办</a-button>-->
  <!--        <a-divider type="vertical"/>-->
  <!--        <a-popconfirm title="确定要作废吗?" @confirm="() => invalidProcess(model)">-->
  <!--          <a-button type="primary" size="small"-->
  <!--                    :disabled="isDisabledAuth('erpSealCertificationUseRecord:invalidProcess')">-->
  <!--            作废流程-->
  <!--          </a-button>-->
  <!--        </a-popconfirm>-->
  <!--        <a-divider type="vertical"/>-->
  <!--      </template>-->
  <!--      <template v-if="model.bpmStatus !== '1'">-->
  <!--        <a-button type="primary" size="small" @click="handleTrack(model)"-->
  <!--                  :disabled="isDisabledAuth('erpSealCertificationUseRecord:viewTrack')">审批进度-->
  <!--        </a-button>-->
  <!--      </template>-->
      </template>
      <!-- <biz-his-task-module ref="bizHisTask" :formData="formData">
        <a-row type="flex" justify="center">
          <a-col :span="24">
            <erp-seal-certification-use-record-form ref="realForm" :disabled="true"
                                                    normal></erp-seal-certification-use-record-form>
          </a-col>
        </a-row>
      </biz-his-task-module> -->
      <div>
        <erp-seal-certification-use-record-form ref="realForm" :disabled="true" normal></erp-seal-certification-use-record-form>
        <!-- 流程历史跟踪 -->
        <common-flow-list v-if="model.bpmStatus !== '1'" :formData="formData"></common-flow-list>
      </div>

      <erp-seal-certification-use-record-modal ref="modalForm"
                                              @ok="modalFormOk"></erp-seal-certification-use-record-modal>
      <bpm-biz-task-deal-modal ref="taskDealModal" :path="path" :formData="formData"
                              @ok="handleOk"></bpm-biz-task-deal-modal>
      <bpm-process-track-modal ref="bpmProcessTrackModal"></bpm-process-track-modal>
      <biz-task-notify-modal ref="taskNotifyModal"></biz-task-notify-modal>
      <biz-task-notify-me-modal ref="taskNotifyMeModal"></biz-task-notify-me-modal>
    </a-card>
    <div style="text-align: center;margin-top: 15px;">
      <a-button v-print="'#printContent'" type="primary">打印</a-button>
    </div>

    <ErpSealCertificationUseRecordFormPrint :formData="model" id="printContent" class="print_style" :formDataHistory="formData" :detail="true" ></ErpSealCertificationUseRecordFormPrint>
  </div>
</template>

<script>


import { getAction } from '@/api/manage'
import { JeecgBpmListMixin } from '@/mixins/JeecgBpmListMixin'
import BizHisTaskModule from '@/views/modules/bpmbiz/common/BizHisTaskModule.vue';
import BpmBizTaskDealModal from '@/views/modules/bpmbiz/common/BpmBizTaskDealModal.vue';
import BpmProcessTrackModal from '@/views/modules/bpmbiz/common/BpmProcessTrackModal.vue';
import BizTaskNotifyModal from '@/views/modules/bpmbiz/common/BizTaskNotifyModal.vue';
import BizTaskNotifyMeModal from '@/views/modules/bpmbiz/common/BizTaskNotifyMeModal.vue';
import ErpSealCertificationUseRecordForm
  from '@/views/erp/administration/seal/modules/ErpSealCertificationUseRecordForm'
import ErpSealCertificationUseRecordModal
  from '@/views/erp/administration/seal/modules/ErpSealCertificationUseRecordModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
import CommonFlowList from '@/views/components/CommonFlowList.vue' // 审批历史流程列表组件
import ErpSealCertificationUseRecordFormPrint from './modules/ErpSealCertificationUseRecordFormPrint' // 打印组件

export default {
  name: 'ErpSealCertificationUseRecordDetail',
  mixins: [JeecgBpmListMixin, DisabledAuthFilterMixin],
  components: {
    ErpSealCertificationUseRecordForm,
    ErpSealCertificationUseRecordModal,
    BizHisTaskModule,
    BpmBizTaskDealModal,
    BpmProcessTrackModal,
    BizTaskNotifyModal,
    BizTaskNotifyMeModal,
    CommonFlowList,
    ErpSealCertificationUseRecordFormPrint
  },
  data() {
    return {
      model: {},
      id: '',
      url: {
        queryById: '/api/erp/administration/seal/erpSealCertificationUseRecord/queryById',
        delete: '/api/erp/administration/seal/erpSealCertificationUseRecord/delete',
        bizCount: '/api/erp/administration/seal/erpSealCertificationUseRecord/bizCount',
      },
      confirmLoading: false,
      iconStyle: { 'font-size': '20px' },
      //代码生成后需手动设置流程编码
      flowCode: 'dev_erp_seal_usage_information_001',
      formUrl: 'erp/administration/seal/modules/ErpSealCertificationUseRecordForm',
      formUrlMobile: '',
    }
  },
  created() {
  },
  watch: {
    $route(to, from) {
      this.loadData();
    },
  },
  mounted() {
  },
  methods: {
    loadData() {
      const id = this.$route.params.id;
      getAction(this.url.queryById, { id }).then((res) => {
        if (res.success) {
          const model = res.result
          // model.id = res.result.masterId
          this.$refs.realForm.edit(model);
          this.model = model;
          //查询催办
          let params1 = { flowCode: this.flowCode, dataId: id };//查询条件
          getAction(this.url.checkNotify, params1).then((res2) => {
            if (res2.result) {
              this.model.taskUrge = true;
            }
          })
          //查询流程
          let params = { flowCode: this.flowCode, dataId: this.model.id };//查询条件
          this.viewTrack(params);
        }
      })
      this.bizCountById(id);
    },
    handleProcess(record) {
      this.getBizProcessNodeInfo(record);
    },
    getBizProcessNodeInfo(record) {
      var params = {flowCode: this.flowCode, dataId: record.masterId};//查询条件
      getAction(this.url.getBizProcessNodeInfo, params).then((res) => {
        if (res.success) {
          var data = {
            dataId: res.result.dataId,
            taskId: res.result.taskId,
            taskDefKey: res.result.taskDefKey,
            procInsId: res.result.procInsId,
            tableName: res.result.tableName,
            permissionList: res.result.permissionList,
            bizTaskList: res.result.bizTaskList,
            vars: res.result.records
          }
          this.formData = data;
          let tempFormUrl = res.result.formUrl;
          //节点配置表单URL，VUE组件类型对应的拓展参数
          if (tempFormUrl && tempFormUrl.indexOf("?") != -1 && !isURL(tempFormUrl) && tempFormUrl.indexOf("{{DOMAIN_URL}}") == -1) {
            tempFormUrl = res.result.formUrl.split("?")[0];
            //update--begin--autor:taoyan-----date:20200729------for：支持新版代码生成器，简易实现表单带button编辑效果------
            let qv = getQueryVariable(res.result.formUrl)
            this.formData.extendUrlParams = qv
            if (qv.edit == 1) {
              this.formData['disabled'] = false
            }
            //update--end--autor:taoyan-----date:20200729------for：支持新版代码生成器，简易实现表单带button编辑效果------
          }
          this.path = tempFormUrl;
          this.$refs.taskDealModal.deal(data);
          this.$refs.taskDealModal.title = "流程办理";
        }
      })
    },
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

.info {
  /deep/ .ant-card-head-title {
    flex: none;
    margin-right: 20px;
  }

  /deep/ .ant-card-extra {
    flex: 1;
    float: left;
  }
}
.print_style{
  position: absolute;
  top: 0;
  z-index: -1111;
}
</style>
<style>
  @import "../../../../utils/print.css";
</style>